const app = getApp(); //引入导航

import { ycOrder } from 'ycOrder.model.js';
var yorder = new ycOrder();
Page({
  data: {
    showIcon: true,
    //显示返回键以及首页
    list_num: 1
  },
  onLoad: function (options) {
    var state = '1';
    this.data.state = state;
    tt.setStorageSync('stateYC', state);

    this._loadDate();
  },
  _loadDate: function () {
    yorder.getTicket(this.data.state, data => {
      //查询出演出订单数据
      console.log(data);
      this.setData({
        'listfint': data
      });
    });
  },
  // 点击切换
  listClick: function (e) {
    var state = e.target.dataset.state;

    if (state) {
      tt.setStorageSync('stateYC', state);
    } else {
      state = tt.getStorageSync("stateYC");
    }

    this.data.state = state;
    yorder.getTicket(this.data.state, data => {
      //查询出演出订单数据
      this.setData({
        'listfint': data,
        'list_num': e.target.dataset.num
      });
    });
  },
  TuiKuan: function (e) {
    var oid = e.target.dataset.oid;
    this.data.oid = oid;
    yorder.getYCTuiKuan(this.data.oid, data => {
      //查询出演出订单数据
      console.log(data);
      this.listClick(e);
    });
  },
  ShenHe: function (e) {
    this.showMessage('已提交，请等待审核!');
  },
  //弹框
  showMessage: function (text) {
    var that = this;
    that.setData({
      showMessage: true,
      messageContent: text
    });
    setTimeout(function () {
      that.setData({
        showMessage: false,
        messageContent: ''
      });
    }, 1000);
  }
});